<?php
/**
 * @author ykm 2016/5/17
 * @describe 添加商家备注 数据转换
 */
class erpapi_shop_response_remark extends erpapi_shop_response_abstract{

    /**
     * @param $params array
     * @return array (
     *              'tid' => '54554', #订单编号
     *              'remark' => '备注信息',
     *              'modified' => '' #修改时间
     *          )
     */
    protected function _formatParams($params) {
        return array();
    }
    #添加商家备注
    public function add($params){
        $sdf = $this->_formatParams($params);
        $this->__apilog['title'] = '接受(' . $this->__channelObj->channel['name'] . ')商家备注';
        if(empty($sdf)) {
            $this->__apilog['result']['msg'] = '不接受商家备注';
            return false;
        }
        $order_bn = $sdf['tid'];
        $shop_id = $this->__channelObj->channel['shop_id'];
        $this->__apilog['original_bn'] = $order_bn;
        $field = 'order_id,process_status,ship_status,custom_mark,mark_text';
        $tgOrder = $this->getOrder($field, $shop_id, $order_bn);
        if($tgOrder) {
            $tgOrder['mark_text'] = $tgOrder['mark_text'] ? unserialize($tgOrder['mark_text']) : array();
            $tgOrder['new_mark'] = array('op_name'=>$this->__channelObj->channel['name'],'op_content'=>$sdf['remark'],'op_time'=>$sdf['modified']);
            return $tgOrder;
        } else {
            $this->__apilog['result']['msg'] = '缺少订单';
            return false;
        }
    }
}